//
//  SmsCloudBannerView.m
//  smsCloud
//
//  Created by 蓝鳍互娱 on 2024/7/18.
//

#import "SmsCloudBannerView.h"
@interface SmsCloudBannerView()<SDCycleScrollViewDelegate>
@property (nonatomic,strong) SDCycleScrollView *smsCloudBannerScrollView;
@end
@implementation SmsCloudBannerView
-(instancetype)initWithFrame:(CGRect)frame{
    if (self == [super initWithFrame:frame]) {
        [self smsCloudInitView];
    }
    return self;
}
- (void)smsCloudInitView{
    //本地图片轮播初始化方式
    _smsCloudBannerScrollView = [SDCycleScrollView cycleScrollViewWithFrame:self.bounds shouldInfiniteLoop:true imageNamesGroup:@[@"smsCloudBanner_1",@"smsCloudBanner_2"]];
    _smsCloudBannerScrollView.backgroundColor = [UIColor clearColor];
    _smsCloudBannerScrollView.delegate = self;
    _smsCloudBannerScrollView.autoScrollTimeInterval = 3;
    _smsCloudBannerScrollView.autoScroll = YES;
    _smsCloudBannerScrollView.bannerImageViewContentMode = UIViewContentModeScaleToFill;
    _smsCloudBannerScrollView.showPageControl = YES;
    //翻页的位置
    _smsCloudBannerScrollView.pageControlAliment = SDCycleScrollViewPageContolAlimentCenter;
    _smsCloudBannerScrollView.currentPageDotColor = [SmsCloudHead SmsCloudColorHexString:@"#FFFFFF"];
    _smsCloudBannerScrollView.pageDotColor = [SmsCloudHead SmsCloudColorHexString:@"#FFFFFF" withAlpha:0.7];
    _smsCloudBannerScrollView.pageControlBottomOffset = [SmsCloudHead SmsCloudScreewRatio:170];
    [self addSubview:_smsCloudBannerScrollView];
    [_smsCloudBannerScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(@([SmsCloudHead SmsCloudScreewRatio:0]));
    }];
}
#pragma mark -- SDCycleScrollViewDelegate
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index{
    if(self.SmsCloudBannerBlock){
        self.SmsCloudBannerBlock(index);
    }
}
@end
